package com.collection;

import java.util.HashSet;
import java.util.Set;

public class OverrideHashCodeEqualTest {

	public static void main(String[] args) {
		Set<Person> set = new HashSet<Person>();// 定义一个HashSet存放person对象
		Person person1 = new Person();
		person1.setName("zhang");
		person1.setAge(18);
		Person person2 = new Person();
		person2.setName("zhang");
		person2.setAge(18);
		System.out.println("返回结果：" + person1.equals(person2));
		set.add(person1);
		set.add(person2);
		System.out.println("set存在" + set.size() + "个对象\n" + set);
		System.out.println("person1's hashcode: " + person1.hashCode());
		System.out.println("person2's hashcode: " + person2.hashCode());
		
	}
}
